using System.Collections;
using UnityEngine;

public class FreezingTrap : MonoBehaviour
{
	public GameObject GO_Parent;

	public Rigidbody2D rb;

	public Collider2D col;

	public SpriteRenderer SR_IMG_FreezingTrap;

	public SpriteRenderer[] SRList;

	public AttackInfo SCRT_AttackInfo;

	public Animator at;

	public void Init(float[] data)
	{
		StopAllCoroutines();
		at.enabled = false;
		SR_IMG_FreezingTrap.sprite = Sprites.instance.etcSpriteList[4];
		SRList[0].color = new Color(1f, 1f, 1f, 0f);
		SRList[1].color = new Color(1f, 1f, 1f, 0f);
		at.StopPlayback();
		col.enabled = false;
		rb.velocity = new Vector2(data[0], data[1]);
		SCRT_AttackInfo.weaponID = 2;
		SCRT_AttackInfo.force = Vector2.zero;
		SCRT_AttackInfo.power = (int)data[2];
		SCRT_AttackInfo.time = data[3];
		StartCoroutine(IE_ActiveTimer(2f, 30f));
	}

	private void OnTriggerEnter2D(Collider2D collision)
	{
		if (collision.CompareTag("Enemy"))
		{
			Generator.instance.SpawnObj(25, collision.transform.position, new float[0], collision.transform);
		}
	}

	private IEnumerator IE_ActiveTimer(float activeTimer, float deactiveTimer)
	{
		yield return new WaitForSeconds(activeTimer);
		SR_IMG_FreezingTrap.sprite = Sprites.instance.etcSpriteList[5];
		Audio.instance.sfx[40].Play();
		yield return new WaitForSeconds(0.1f);
		at.enabled = true;
		SRList[0].color = new Color(1f, 1f, 1f, 1f);
		SRList[1].color = new Color(1f, 1f, 1f, 1f);
		yield return new WaitForSeconds(deactiveTimer);
		SR_IMG_FreezingTrap.sprite = Sprites.instance.etcSpriteList[4];
		SRList[0].color = new Color(1f, 1f, 1f, 0f);
		SRList[1].color = new Color(1f, 1f, 1f, 0f);
		Audio.instance.sfx[40].Play();
		yield return new WaitForSeconds(0.5f);
		GO_Parent.SetActive(false);
	}

	public void ColSwitch(int swt)
	{
		if (swt == 0)
		{
			col.enabled = false;
			return;
		}
		col.enabled = true;
		Audio.instance.sfx[39].Play();
	}
}
